﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;

namespace RockBus.DataContracts
{
    [DataContract(Namespace = StringConstants.RockBusNamespace)]
    public class TopicInfo
    {
        public TopicInfo()
        {
        }

        public TopicInfo(string name)
        {
            this.Name = name;
        }

        [DataMember]
        public string Name { get; set; }
    }

    [CollectionDataContract(Namespace = StringConstants.RockBusNamespace)]
    public class TopicInfoCollection : Collection<TopicInfo>
    {
        public TopicInfo this[string name]
        {
            get
            {
                return this.FirstOrDefault<TopicInfo>((ti) => StringComparer.InvariantCultureIgnoreCase.Compare(ti.Name, name) == 0);
            }
        }
    }
}